import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
plt.rcParams.update({'font.size': 16, 'figure.figsize': (13, 6)})

df = pd.read_csv('data/precision.csv')

fig = plt.figure()
gs = fig.add_gridspec(1, 2, wspace=.05)
ax =gs.subplots(sharey=True)

sns.lineplot(x='pred_pos', y='m_precision', hue='classifier', data=df.loc[df['endo']== 0], ax=ax[0])
ax[0].set_xlabel('predicted repayment rank') 
ax[0].set_ylabel('share with 3M repayment > 20\%')
ax[0].set_title('exogenous covs\n')

sns.lineplot(x='pred_pos', y='m_precision', hue='classifier', data=df.loc[df['endo']== 1], ax=ax[1])
ax[1].set_title('endogenous covs\n')
ax[1].set_xlabel('predicted repayment rank') 

plt.savefig('figs/figOF1.pdf')
